package br.uece.laconi.tac.adapt;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

import se.sics.tac.aw.Bid;
import se.sics.tac.aw.TACAgent;

import jmetal.util.JMException;
import br.uece.laconi.tac.Agent;
import br.uece.laconi.tac.Alocador;
import br.uece.laconi.tac.ga.GA4TAC;

/**
 * @author robson
 */
public class AdaptAllocation extends Timer {
	private Alocador ga = null;
	
	public AdaptAllocation(Alocador alocador) {
		this.ga = alocador;
	}
	
	public void init(long delay){
		TimerTask risc;
		risc = new AdaptBehaviorJob(ga);
		new Timer().schedule(risc, delay);
	}

	class AdaptBehaviorJob extends TimerTask {
		Alocador ga;
		public AdaptBehaviorJob (Alocador ga) {
			this.ga = ga;
		 }

		 public void run() {
			try {
				System.out.println("############### RODOU ALGORITMO GENETICO ###############");
				ga.solve();
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JMException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			};
			this.cancel();
		}
	} 
}